package com.zh.demo.controller;

import com.zh.demo.entity.User;
import com.zh.demo.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yufei
 * @since 2018-12-13
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

	@Autowired private IUserService userService;

	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public void addUser(@RequestParam("name") String name, @RequestParam("passward") String passward) {
		log.error("Jin lai le");
		log.info("获取到的name为：{},password为：{}", name, passward);
		userService.add(name, passward);
	}


	@RequestMapping(value = "/searchPageList", method = RequestMethod.POST)
	public List<User> searchPageList() {
		return userService.list();
	}
}
